#include<vector>
using namespace std;
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int val = 0;
        for (auto& x : nums)
        {
            val ^= x;
        }
        int pos = 0;
        while ((val & 1) != 1)
        {
            val = val >> 1;
            pos++;
        }
        vector<int> v1;
        vector<int> v2;
        for (auto& x : nums)
        {
            if (((x >> pos) & 1) == 1)
            {
                v1.push_back(x);
            }
            else
            {
                v2.push_back(x);
            }
        }
        int ret1 = 0, ret2 = 0;
        for (auto& x : v1)
        {
            ret1 ^= x;
        }
        for (auto& x : v2)
        {
            ret2 ^= x;
        }
        vector<int> ret;
        ret.push_back(ret1);
        ret.push_back(ret2);
        return ret;

    }
};